import pagination from '@/views/pagination'  //分页组件
import Popup from './edit'   //弹窗组件
import agentHttp from '@/utils/agentHttp.js'
import {debounce} from '@/utils/index.js'
export default {
  name: 'priceAudit',
  created(){
   this.seachData()
  },
  components:{
    Popup,
    pagination
  },
  data() {
  	return {
      //搜索字段
  		searchForm:{
  			dealerName:"",
        orderNumber:"",
        startDate:"",
        endDate:"",
        status:"",
      },
      //表格字段
       tableData: [],
         
      formLabelWidth:'120px',
      statusMap:'',
      //发送给弹窗的数据
      dialogSendData:{
        isAdd:true,                //是否为编辑或者新增  true是   false否
        dialogFormVisible:false,   //弹窗是否显示        true是   false否
        id:""          //请求参数            自定义 例如index或者id
      },
      startDateOpt: {
        disabledDate(time) {
          return time.getTime() > Date.now() 
        }
      },
      endDateOpt:{
        disabledDate:(time)=>{
          return  time.getTime()< new Date(this.searchForm.startDate).getTime();
        }
      },
       mortgageOrderExtendId:'',//传给子组件的id
      resetFormStatus:false
      
  	}
  },

  methods: {
    seachData(){       
        var params=this.searchForm||{};
        params.page=this.tableData.page||1;
        params.rows=this.tableData.rows||10;
        agentHttp.postJson('adminApi/admin/mortgage_order_risk/refund_order_list?page='+params.page+'&rows='+params.rows,params ).then((data)=>{
              
              this.tableData = data.data.orderInfo;
              this.statusMap=data.data.statusMap;
             
              
        })
      },
    formIsEdit(e){       //点击按钮，表单是否查看还是编辑
       let value = e.currentTarget.innerText ;
       this.dialogSendData.dialogFormVisible=true; 
       this.mortgageOrderExtendId =  e.currentTarget.dataset.id     //传递给子组件的id         
        // this.dialogSendData.id=row.id;
       
       if(value==='审核'){  //可编辑
        this.dialogSendData.isAdd=false;
       }else{           //不可被编辑
        this.dialogSendData.isAdd=true;
       }
    },
    debounceSeach(){      //input框内容发生改变时，调接口显示查询结果
      this.tableData.page=1;
      debounce(this.seachData(this.searchForm),1000)
    },
    resetSearchForm(formName){
      this.$refs[formName].resetFields();
      this.seachData()
    },
   
  }
}